﻿#ifndef __PICKER_H__
#define __PICKER_H__

#include <QWidget>
#include <QEvent>
#include <QScrollArea>
#include <QList>
#include <QMouseEvent>
#include <QStyleOption>

#include "shape/rhomboidshape.h"
#include "shape/rectangleshape.h"
#include "shape/rounderrectshape.h"
#include "shape/cloudshape.h"
#include "shape/circleshape.h"
#include "paint/borderpainter.h"
#include "paint/shapepainter.h"


class Picker : public QWidget
{
	Q_OBJECT
private:
	//可以选择的图形
	QList<Shape*> pickable_shape;
	//一行摆放的数量
	int pickable_count;
	//摆放的图形大小
	int pickable_width;
	//摆放图形的间隔
	int pickable_space;
	//临时拖拽的图形
	Shape* selected_shape;
	//判断是否已创造
	bool is_leave;
public:
	explicit Picker(QWidget* parent = nullptr);
	Shape* getSelectShape() const;
	static Shape* getShape(ShapeType type);
protected:
	void paintEvent(QPaintEvent* event) override;
	void resizeEvent(QResizeEvent* event) override;
	void mousePressEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;

signals:
	//当图形拖拽到picker外时触发
	void startCreate();
	//当鼠标拖拽到picker外时触发
	void resetCreate(const QPoint& point);
	//当图形重回到picker内时触发
	void pauseCreate();
	//当图形拖拽完松开鼠标时触发
	void finalCreate();
};




#endif // !__PICKER_H__
